package com.heima.user.feign;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.apis.apuser.IApUserClient;
import com.heima.model.user.dtos.ApUserAuthPageReqDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserAuthService;

import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:Dikk
 * @create: 2023-08-02 09:19
 * @Description: ApUserClient
 */
@RestController
public class ApUserClient implements IApUserClient {

    @Autowired
    private ApUserAuthService apUserAuthService;
    @Autowired
    private ApUserService apUserService;

    /**
     * 获取用户认证列表
     *
     * @param apUserAuthPageReqDTO
     * @return
     */
    @PostMapping("/api/v1/apuser/auth/list")
    @Override
    public ResponseResult authList(ApUserAuthPageReqDTO apUserAuthPageReqDTO) {
        return apUserAuthService.authList(apUserAuthPageReqDTO);
    }

    /**
     * 审核
     *
     * @param apUserAuthPageReqDTO
     * @return
     */
    @PostMapping("/api/v1/apuser/auth/auth")
    @Override
    public ResponseResult authPass(ApUserAuthPageReqDTO apUserAuthPageReqDTO) {
        return apUserAuthService.authPass(apUserAuthPageReqDTO);
    }

    /**
     * 根据用户id获取用户信息
     *
     * @param id
     * @return
     */
    @Override
    public ApUser findUserById(Integer id) {
        return apUserService.getOne(Wrappers.<ApUser>lambdaQuery().eq(ApUser::getId, id));
    }

}
